import { exportUrl, downloadTemplateUrl, getIsReviewList } from "@/api/record/mesScanRecordDefective"

import { exportExcel } from "@/utils/judge"

// 列表头按钮配置
export const operateList = [
  {
    name: $i18n.t("common.export"),
    type: "primary",
    icon: "el-icon-download",
    handleName: "export", //点击时返回的标识
    url: exportUrl
    //auth: "auth:operlog:export", //权限字段
  },
  {
    name: $i18n.t("mesScanRecordDefective.createReviewOrder"),
    type: "primary",
    icon: "el-icon-circle-plus-outline",
    handleName: "createReview", //点击时返回的标识
    isMultiple: true // isSingle 表示必须选择一项//isMultiple: true, // 表示必须多选
  }
  // {
  //   name: $i18n.t("common.delete"),
  //   type: "danger",
  //   icon: "el-icon-delete",
  //   handleName: "deleteBatch", //点击时返回的标识
  //   isMultiple: true, // isSingle 表示必须选择一项//isMultiple: true, // 表示必须多选
  // },
  // {
  //   name: "导入",
  //   type: "primary",
  //   icon: "el-icon-circle-plus-outline",
  //   handleName: "import", //点击时返回的标识
  // },
]
// 行末按钮配置
export const rowConfig = [
  {
    name: $i18n.t("common.edit"),
    type: "primary",
    class: "row-btn-primary",
    handleName: "edit" //点击时返回的标识
  },
  {
    name: $i18n.t("common.details"),
    type: "info",
    class: "row-btn-info",
    handleName: "detail" //点击时返回的标识
  },
  {
    name: $i18n.t("common.delete"),
    type: "danger",
    class: "row-btn-danger",
    handleName: "delete" //点击时返回的标识
  }
]
// 搜索条件配置
export const searchConfig = {
  inline: true,
  formDesc: {
    faultName: {
      type: "input",
      label: $i18n.t("mesScanRecordDefective.faultName")
    },
    isReview: {
      type: "select",
      label: $i18n.t("mesScanRecordDefective.isReview"),
      prop: {
        value: "value",
        text: "description"
      },
      options: async (data) => {
        const list = await getIsReviewList()
        return list.data.result
      }
    },
    orderCode: {
      type: "input",
      label: $i18n.t("mesScanRecordDefective.orderCode")
    },
    productProcessName: {
      type: "input",
      label: $i18n.t("common.processName")
    },
    prodName: {
      type: "input",
      label: $i18n.t("mesScanRecordDefective.prodName")
    },
    seriesName: {
      type: "input",
      label: $i18n.t("mesScanRecordDefective.seriesName")
    },
    equipmentName: {
      type: "input",
      label: $i18n.t("mesScanRecordDefective.equipmentName")
    },
    reviewCode: {
      type: "input",
      label: $i18n.t("mesScanRecordDefective.reviewCode")
    }
  }
}
// 新增/删除表单配置
export const formDescDialog = {
  span: 24,
  disabled: false,
  isShowSubmitBtn: true,
  formDesc: {
    orderCode: {
      type: "input",
      label: $i18n.t("mesScanRecordDefective.orderCode"),
      layout: 12,
      disabled: true
    },
    productProcessCode: {
      type: "input",
      label: $i18n.t("common.processCode"),
      layout: 12,
      required: false,
      disabled: true
    },
    productProcessName: {
      type: "input",
      label: $i18n.t("common.processName"),
      layout: 12,
      required: false,
      disabled: true
    },
    equipmentCode: {
      type: "input",
      label: $i18n.t("mesScanRecordDefective.equipmentCode"),
      layout: 12,
      required: false,
      disabled: true
    },
    equipmentName: {
      type: "input",
      label: $i18n.t("mesScanRecordDefective.equipmentName"),
      layout: 12,
      required: false,
      disabled: true
    },
    seriesCode: {
      type: "input",
      label: $i18n.t("mesScanRecordDefective.seriesCode"),
      layout: 12,
      required: false,
      disabled: true
    },
    seriesName: {
      type: "input",
      label: $i18n.t("mesScanRecordDefective.seriesName"),
      layout: 12,
      required: false,
      disabled: true
    },
    faultCode: {
      type: "input",
      label: $i18n.t("mesScanRecordDefective.faultCode"),
      layout: 12,
      required: false,
      disabled: true
    },
    faultName: {
      type: "input",
      label: $i18n.t("mesScanRecordDefective.faultName"),
      layout: 12,
      required: false,
      disabled: true
    },
    rejectQuantity: {
      type: "number",
      label: $i18n.t("mesScanRecordDefective.unqualifiedQty"),
      layout: 12,
      disabled: true
    },
    // rejectRatio: {
    //   type: "number",
    //   label: "不合格率",
    //   layout: 12,
    //   disabled: false,
    //   required: true,
    //   attrs: {
    //     min: 0,
    //   },
    // },
    description: {
      type: "textarea",
      label: $i18n.t("mesScanRecordDefective.description"),
      layout: 24,
      required: true
    }
  }
}
//导入数据
export const importFormDescDialog = {
  span: 24,
  disabled: false,
  isShowSubmitBtn: true,
  formDesc: {
    model: {
      type: "button",
      label:"",// $i18n.t("mesScanRecordDefective.model"),
      layout: 24,
      required: false,
      title: $i18n.t('common.downloadTemplate'),
      style: {
        color: "#1867c0",
        fontSize: "14px"
      },
      on: {
        click: () => {
          exportExcel(downloadTemplateUrl)
        }
      }
    },
    file: {
      type: "input",
      label: $i18n.t("mesScanRecordDefective.file"),
      layout: 24
      // required: true,
    }
  }
}
